<?php
/**
 * Created by PhpStorm.
 * User: qishengqiang
 * Date: 2022-06-03
 * Time: 11:03
 */

namespace app\models;


class Goods extends ModelBase
{
    protected $pk = 'goodsId';

    public function getCategoryName()
    {
        if ($this->categoryId == 1) {
            return '虚拟商品';
        } elseif ($this->categoryId == 2) {
            return '实物商品';
        }
    }

    public function getStatusText()
    {
        if ($this->status == 1) {
            return '上架';
        } elseif ($this->status == 0) {
            return '下架';
        }
    }

    public function getModels()
    {
        $models = GoodsModels::where(['modelId' => explode(',',$this->models)])->select();

        return $models;
    }

    public function getModelIds()
    {
        $modelIds = GoodsModels::where(['modelId' => explode(',',$this->models)])->column('modelId');

        return $modelIds;
    }
}